import 'package:safetymonitor/app/components/custom_modele/custom_icon_title_view.dart';
import 'package:safetymonitor/app/core/core.dart';

///总览页面-带标题的父类布局
///[child]显示的子类
///[title]显示的标题
///[titleView]自定义样式标题
///[contentPadding]内容内边距
///[checkbox]内容选框
///[mainAxisSize]max/min
///[isShowTitleRightWidget]title右边扩展的布局
/// demo:
/// ``` dart
/// CustomTitleChartPage(
///   child: widget,
/// );
/// ```
class CustomTitleChartPage extends StatelessWidget {
  const CustomTitleChartPage({
    required this.child,
    super.key,
    this.title,
    this.titleColor,
    this.titleView,
    this.contentPadding,
    this.titleRightWidget,
    this.isShowTitleRightWidget,
    this.checkbox,
    this.leftIcon,
    this.mainAxisSize = MainAxisSize.max,
  });

  final Widget child;
  final String? title;
  final Color? titleColor;
  final Widget? titleView;
  final EdgeInsetsGeometry? contentPadding;
  final Widget? titleRightWidget;
  final Widget? isShowTitleRightWidget;
  final Widget? checkbox;
  final Widget? leftIcon;
  final MainAxisSize mainAxisSize;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10.w),
      ),
      child: Column(
        mainAxisSize: mainAxisSize,
        children: [
          title != null
              ? CustomIconTitleView(
                  checkbox: checkbox,
                 leftIcon: leftIcon,
                  title: title!,
                 titleColor: titleColor ,
                  titleRightWidget: titleRightWidget,
                  isShowTitleRightWidget: isShowTitleRightWidget,
                )
              : Container(),
          titleView != null ? titleView! : Container(),
          Container(
            color: const Color(0xFF587DF5).withOpacity(0.2),
            height: 1.w,
          ),
          Container(
            padding: contentPadding ?? EdgeInsets.symmetric(horizontal: 16.w, vertical: 20.w),
            child: child,
          )
        ],
      ),
    );
  }
}
